<?php

namespace App\Http\Validate\Receivemoney;

use App\Http\Validate\BaseValidate;

/**
 * 认款单验证器
 */
class Receivemoney extends BaseValidate
{
    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'firm_name' => 'required',
                'amount' => 'required',
                'date' => 'required',
                'settlement_company' => 'required',
                'bank_name' => 'required',
//                'settlement_category' => 'required',
                'settlement_category_id' => 'required',
            ];
            $this->message = [
                'firm_name.required' => '公司名称不能为空',
                'amount.required' => '金额不能为空',
                'date.required' => '打款时间不能为空',
                'settlement_company.required' => '结算公司不能为空',
                'bank_name.required' => '银行名称不能为空',
//                'settlement_category.required' => '结算方式不能为空',
                'settlement_category_id.required' => '结算方式id不能为空',
            ];
        } elseif ($doaction == 'edit') {
            $this->rule = [
                'id' => 'required',
                'firm_name' => 'required',
                'amount' => 'required',
                'date' => 'required',
                'settlement_company' => 'required',
                'bank_name' => 'required',
//                'settlement_category' => 'required',
                'settlement_category_id' => 'required',
            ];
            $this->message = [
                'id.required' => '认款单id不能为空',
                'firm_name.required' => '公司名称不能为空',
                'amount.required' => '金额不能为空',
                'date.required' => '打款时间不能为空',
                'settlement_company.required' => '结算公司不能为空',
                'bank_name.required' => '银行名称不能为空',
//                'settlement_category.required' => '结算方式不能为空',
                'settlement_category_id.required' => '结算方式id不能为空',
            ];
        } elseif ($doaction == 'sentout') {
            $this->rule = [
                'id' => 'required',
            ];
            $this->message = [
                'id.required' => '认款单id不能为空',
            ];
        } elseif ($doaction == 'move') {
            $this->rule = [
                'id' => 'required',
                'receiver_id' => 'required',
                'new_receiver_id' => 'required',
                'firm_name' => 'required',
                'settlement_company' => 'required',
                'amount' => 'required',
            ];
            $this->message = [
                'id.required' => '认款单id不能为空',
                'receiver_id.required' => '认款人id不能为空',
                'new_receiver_id.required' => '新认款人id不能为空',
                'firm_name.required' => '公司名称不能为空',
                'settlement_company.required' => '结算公司不能为空',
                'amount.required' => '金额不能为空',
            ];
        }
    }
}
